﻿package {
	
	import flash.events.Event;
	
	public class Sludge extends ICharacter{
		
		private var _origspeed;
		private var _origheight;
		private var _sliming = false;
		
		public function Sludge(){
			_fallspeed = 2;
			_jumpheight = 20;
			_origheight = height;
			_special_1_keydown_action = init_special_action;
			_special_1_keyup_action = undo_special_action;
			addEventListener("enterFrame", moveDown);
		};
													
		private function init_special_action(){
			gotoAndStop("slime");
			_sliming = true;
			_speed = 1;
			_fallspeed = 5;
			_jumpheight = 0;
			
		}
		
		private function undo_special_action(){
			gotoAndStop("standing")
			_sliming = false;
			_speed = _origspeed;
			_fallspeed = 2;
			_jumpheight = 20;
		}
		
		override public function set speed(val:int):void{
			_speed = _origspeed = val;
		}
		
		
		override public function moveLeft(evt:Event):void{
			x -= _speed;
			
			if (!_falling && !_boundaries.hitTestPoint(x, y+(_origheight/2), true) && !_boundaries.hitTestPoint(x-(width/2), y+(_origheight/2), true) && !_boundaries.hitTestPoint(x-(width/2), y-(_origheight/2), true) ){
				_myJump = _fallspeed;
				addEventListener("enterFrame", moveDown);
			}
			
			checkBounds();
		}
		
		override public function moveRight(evt:Event):void{
			x += _speed;
			
			if (!_falling && !_boundaries.hitTestPoint(x, y+(_origheight/2), true) && !_boundaries.hitTestPoint(x-(width/2), y+(_origheight/2), true) && !_boundaries.hitTestPoint(x-(width/2), y-(_origheight/2), true) ){
				_myJump = _fallspeed;
				addEventListener("enterFrame", moveDown);
			}
			
			checkBounds();
		}
	}
	
}